function startselect()
{
 square.CM = true;
 square.SX = square.style.pixelLeft = event.clientX + document.body.scrollLeft;
 square.SY = square.style.pixelTop = event.clientY + document.body.scrollTop;
 
 with(square.style)
 {
  pixelWidth = 0;
  pixelHeight = 0;
  visibility = "visible";
 } 
}

function inselect()
{
 if(square.CM)
 {
  var Jx=Jy=0
  var SX = square.SX
  var SY = square.SY
  
  if((Jx=document.body.scrollLeft+event.clientX)>SX)
  {
   square.style.pixelLeft = SX;
   square.style.pixelWidth = Jx-SX;
  }
  else
  {
   square.style.pixelLeft = Jx;
   square.style.pixelWidth = SX-Jx;   
  }
  if((Jy=document.body.scrollTop+event.clientY)>SY)
  {
   square.style.pixelTop = SY;
   square.style.pixelHeight = Jy-SY;
  }
  else
  {
   square.style.pixelTop = Jy;
   square.style.pixelHeight = SY-Jy;  
  }  
  
  //box.value = square.style.pixelLeft+" "+square.style.pixelTop+" "+square.style.pixelWidth+" "+square.style.pixelHeight;
  unitprop3.value=square.style.pixelLeft;
  unitprop4.value=square.style.pixelTop;
  unitprop5.value=square.style.pixelWidth;
  unitprop6.value=square.style.pixelHeight;
 }
 
}

function endselect()
{
 with(square)
 {
  CM = false;
  style.visibility = "hidden";
 }
 generateunit(curUnittype);
}